package com.xcode.xandrdb.Catch;

import java.util.HashMap;
import java.util.Map;

//import com.xcode.xandrdb.Session.SessionApplication;
//import com.xcode.xandrdb.util.RAMUtil;

/**
 * 用于保存查询语句，以及相对应的结果作为缓存
 * @author xiaolei
 */
public class DefaultSelectCatch
{
	private final static DefaultSelectCatch s_Catch = new DefaultSelectCatch();
	private Map<String, Object> map = new HashMap<String,Object>();
//	private long memoryCanUse = RAMUtil.getAvailableMemory(SessionApplication.getInstance());
	private DefaultSelectCatch()
	{
	}
	public static DefaultSelectCatch getInstance()
	{
		return s_Catch;
	}
	
	public void putCatch(String key,Object value)
	{
		map.put(key, value);
	}
	
	public Object getCatch(String key)
	{
		return map.get(key);
	}
	
	/**
	 * 获取已缓存的所占的内存大小
	 * @return
	 */
	public long getMemorySize()
	{
		return 0;
	}
	
	public void Clean()
	{
		map.clear();
	}
	public void remove(String key)
	{
		map.remove(key);
	}
	public void removeAll()
	{
		map.clear();
	}
	
}
